import axios from 'axios';
import { Result } from "../common/Result";
import querystring from "querystring";
const get = (url, params) => axios.get(url, { params: params });

const post = (url, data) => axios.post(url, data);

axios.interceptors.response.use(response => new Result(response.data))
axios.interceptors.request.use(request => {
    if (request.method.toLocaleUpperCase() === "POST" && request.data) {
        request.data = querystring.stringify(request.data);
    }
    return request;
})
export { get, post };